package com.upb.webserver.common.pojo.account;

import com.upb.webserver.dao.entity.TbDeveloper;
import com.upb.webserver.dao.entity.TbManager;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.experimental.Accessors;
import org.springframework.beans.BeanUtils;

import java.util.Objects;

@Data
@NoArgsConstructor
@AllArgsConstructor
@Accessors(chain = true)
public class AccountCommon {
    private Byte platform;
    private Integer id;
    private String account;
    private String password;
    private Byte status;
    private Integer roleId;
    private String roleName;


    public static AccountCommon.Builder builder() {
        return new AccountCommon.Builder();
    }


    @Setter
    public static class Builder {
        private TbDeveloper developer;
        private TbManager managerRow;


        Builder() {
        }

        public AccountCommon build() {
            AccountCommon account = new AccountCommon();
            if (this.developer != null) {
                BeanUtils.copyProperties(this.developer, account);
            }
            if (this.managerRow != null) {
                BeanUtils.copyProperties(this.managerRow, account);
            }

            return account;
        }
    }
}
